﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace UMLDesigner
{
    public class MethodData
    {
        private string name;
        private List<ParameterData> parameters = new List<ParameterData>();
        private string returnType;
        private string visibility;

        public MethodData(string newVisibility, string newName, string newReturnType)
        {
            name = newName;
            returnType = newReturnType;
            visibility = newVisibility;
        }

        public string GetName()
        {
            return name;
        }

        public void SetName(string newName)
        {
            name = newName;
        }

        public void SetReturnType(string newReturnType)
        {
            returnType = newReturnType;
        }

        public void SetVisibility(string newVisibility)
        {
            visibility = newVisibility;
        }

        public string GetReturnType()
        {
            return returnType;
        }

        public string GetVisibility()
        {
            return visibility;
        }

        public void SetParameters(List<ParameterData> newParameters)
        {
            parameters.Clear();
            for (int i = 0; i < newParameters.Count; i++)
            {
                parameters.Add(newParameters[i]);
            }
        }

        public List<ParameterData> GetParameters()
        {
            return parameters;
        }

        public string GetUMLRepresentation()
        {
            string umlVisibility = VisibilityType.GetUMLRepresentation(visibility);
            string representation = umlVisibility + " " + name + " (";

            for(int i=0; i<parameters.Count; i++)
            {
                representation += parameters[i].GetUMLRepresentation();
                if (i != parameters.Count - 1)
                {
                    representation+=", ";
                }
            }
            representation += ")";
            if (returnType != "void")
            {
                representation += " : " + returnType;
            }
            return representation;
        }

        public void AddParameter(string name, string type)
        {
            ParameterData newParameter = new ParameterData(name, type);
            parameters.Add(newParameter);
        }
       
    }
}
